package yunquan.wang.modules.customer.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import yunquan.wang.base.dao.springdata.BaseRepository;
import yunquan.wang.base.service.impl.BaseServiceImpl;
import yunquan.wang.modules.customer.dao.ContactsDao;
import yunquan.wang.modules.customer.dao.ContactsInfoDao;
import yunquan.wang.modules.customer.entity.Contacts;
import yunquan.wang.modules.customer.service.ContactsService;
@Service("contactsService")
@Transactional(value = "jpaTransaction")
public class ContactsServiceImpl extends BaseServiceImpl<Contacts>
implements ContactsService{

	@Resource
private	ContactsDao contactsDao;
	@Resource
	private ContactsInfoDao contactsInfoDao;
	
	
	@Override
	public BaseRepository<Contacts, String> getDao() {
		return contactsDao;
	}

	public Contacts save(Contacts entity)
	{
		if(entity.isNew())
		{
		 entity.setContactsInfo(contactsInfoDao.save(entity.getContactsInfo()));
		}
	 
			entity=	contactsDao.save(entity);
		 
		return entity;
	}
}
